package com.jzx.provider.cv.controller;

import com.jzx.provider.common.result.InvokeResult;
import com.jzx.provider.cv.dto.command.ProjectInfoCommand;
import com.jzx.provider.cv.service.ProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Size;

/**
 * @author daihuihui
 * @date 2019/2/5
 */
@Validated
@RestController
@RequestMapping("/project")
public class ProjectInfoController {
    @Autowired
    private ProjectInfoService projectInfoService;

    @PostMapping("/saveOrUpdate")
    public InvokeResult<Void> saveOrUpdate(@RequestBody @Validated ProjectInfoCommand projectInfoCommand) {
        projectInfoService.saveOrUpdate(projectInfoCommand);
        return InvokeResult.success();
    }

    @GetMapping("/del/{id}")
    public InvokeResult<Void> deleteProject(@PathVariable Integer id) {
        projectInfoService.deleteProject(id);
        return InvokeResult.success();
    }

    @PostMapping("/saveOrUpdateProjectInfo")
    public InvokeResult saveOrUpdateProjectInfo(@RequestBody @Validated ProjectInfoCommand projectInfoCommand) {
        projectInfoService.saveOrUpdateProjectInfo(projectInfoCommand);
        return InvokeResult.success();
    }
}
